package day01_07.day02;

/**
 *  排序子序列
 *  https://www.nowcoder.com/questionTerminal/2d3f6ddd82da445d804c95db22dcc471?orderByHotValue=1&page=1&onlyReference=false
 */

import java.util.Arrays;
import java.util.Scanner;

public class Main01 {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int count = 0;
        int n = scn.nextInt();

        int[] arr = new int[n + 1];
        for (int i = 0; i < n; i++) {
                arr[i] = scn.nextInt();
        }
        int i = 0 ;
        while (i < n){
            if (arr[i] < arr[i + 1] ){
                while (i < n && arr[i] < arr[i + 1]){
                    i++;
                }
                count ++;
                i++;
            }
            else if (arr[i] == arr[i + 1]){
                i++;
            }
            else if (arr[i] > arr[i + 1]){
                while (i < n && arr[i] > arr[i + 1]){
                    i++;
                }
                count ++;
                i++;
            }
        }
        System.out.println(count);
    }
}
/**
 * 走完在做判断，计数器加一，如果在递减过程中不满足条件就退出并给count加一，如果遇到连续相等直接跳过；
 */
